﻿@model GSLMS.Entity.TB_SYS_EMP
@{
    var upOrgList = ViewData["OrgList"] as SelectList;
}
<div class="pageContent">
    <form method="post" action="System/Employee/Create?OpID=@ViewData["OperateID"]" class="pageForm required-validate"
    onsubmit="return validateCallback(this, dialogAjaxDone);">
    @Html.ValidationSummary(true)
    <div class="pageFormContent" layouth="56">
        @Html.HiddenFor(model => model.ID)
        @Html.Hidden("HID_ISUSER",Model.ISUSER)
        @Html.Hidden("HID_ISLEAVE", Model.ISLEAVE)
        @Html.Hidden("HID_USERNAME", Model.USERNAME)
        <p>
            <label>
                员工编号：</label>
            @Html.TextBoxFor(model => model.EMPNO)
        </p>
        <p>
          <label>
                姓名：</label>
            @Html.TextBoxFor(model => model.EMPNAME, new { @class = "required" })
             @Html.ValidationMessageFor(model => model.EMPNAME)
        </p>
        <p>
          <label>
                身份证号：</label>
            @Html.TextBoxFor(model => model.IDCARD)
        </p>
        <p>
          <label>
                性别：</label>
            @Html.RadioButtonFor(model => model.GENDER, "男", new { @checked = true })
            <span>男&nbsp;</span>
             @Html.RadioButtonFor(model => model.GENDER,"女")
            <span>女&nbsp;</span>
        </p>
        <p>
          <label>
                出生日期：</label>
            @Html.TextBoxFor(model => model.BIRTHDAY, new { @class = "date", @dateFmt = "yyyy-MM-dd", @readonly = "true" })
              <a class="inputDateButton" href="javascript:;">选择</a>
        </p>
        <p>
          <label>
                职务：</label>
            @Html.TextBoxFor(model => model.DUTIES)
        </p>
        <p>
          <label>
                所属部门：</label>
          
              @Html.DropDownListFor(model => model.ORGID, upOrgList, GSLMS.WebAPP.HelperCommon.SelectDefaultValue, new { @class = "combox", @selectedvalue = Model.ORGID })
        </p>
        <p>
          <label>
                是否机构负责人：</label>
           
            @Html.RadioButtonFor(model => model.ISPRINCIPAL, 1)
            <span>是&nbsp;</span>
             @Html.RadioButtonFor(model => model.ISPRINCIPAL, 0)
            <span>否&nbsp;</span>
         </p>
        <p>
          <label>
                电话：</label>
            @Html.TextBoxFor(model => model.TELCODE, new {@style = "float:none;width:40px" })-
            @Html.TextBoxFor(model => model.TEL, new { @style = "float:none;width:70px" })
        </p>
        <p>
          <label>
                手机：</label>
            @Html.TextBoxFor(model => model.MOBILE)
        </p>
        <p>
          <label>
                家庭电话：</label>
           @Html.TextBoxFor(model => model.HOMETELCODE, new {  @style = "float:none;width:40px" })-
            @Html.TextBoxFor(model => model.HOMETEL, new { @style = "float:none;width:70px" })
         </p>
         <p>
          <label>
                办公电话：</label>
            @Html.TextBoxFor(model => model.OFFICETELCODE, new {@style = "float:none;width:40px" })-
            @Html.TextBoxFor(model => model.OFFICETEL, new {@style = "float:none;width:70px" })-
            @Html.TextBoxFor(model => model.OFFICETELSUB, new { @style = "float:none;width:40px" })
         </p>
         <p>
          <label>
                家庭住址：</label>
            @Html.TextBoxFor(model => model.HOMEADDR)
         </p>
         <p>
          <label>
                邮编：</label>
            @Html.TextBoxFor(model => model.POST)
         </p>
         <p>
          <label>
                邮箱：</label>
            @Html.TextBoxFor(model => model.EMAIL)
         </p>
         <p>
          <label>
                是否业务员：</label>
            @Html.RadioButtonFor(model => model.ISSALESMAN, 1)
            <span>是&nbsp;</span>
             @Html.RadioButtonFor(model => model.ISSALESMAN, 0)
            <span>否&nbsp;</span>
              @Html.ValidationMessageFor(model => model.ISSALESMAN)
         </p>
         <p style="display:none;" id="divHolidays">
          <label>
                是否休假：</label>
            @Html.RadioButtonFor(model => model.ISHOLIDAYS, 1)
            <span>是&nbsp;</span>
             @Html.RadioButtonFor(model => model.ISHOLIDAYS, 0)
            <span>否&nbsp;</span>
            @Html.ValidationMessageFor(model => model.ISHOLIDAYS)
         </p>
         <p>
          <label>
                是否离职：</label>
            
            @Html.RadioButtonFor(model => model.ISLEAVE, 1, new { @onclick = "changeShowLevalDate(this.value);" })
            <span>是&nbsp;</span>
             @Html.RadioButtonFor(model => model.ISLEAVE, 0, new { @onclick = "changeShowLevalDate(this.value);" })
            <span>否&nbsp;</span>
            @Html.ValidationMessageFor(model => model.ISLEAVE)
         </p>
         <p style="display:none;" id="divLevalDate">
          <label>
                离职日期：</label>
            @Html.TextBoxFor(model => model.LEAVEDATE, new { @class = "date", @dateFmt = "yyyy-MM-dd", @readonly = "true" })
            <a class="inputDateButton" href="javascript:;">选择</a>
         </p>
      
         <p style=" width:760px;">
          <label>
                备注：</label>
            @Html.TextBoxFor(model => model.REMARK, new { @style = "width:506px;",})
         </p>
         
         <p>
          <label>
                是否操作用户：</label>
             @Html.RadioButtonFor(model => model.ISUSER, 1, new { @onclick = "changeShowDivUser(this.value);" })
            <span>是&nbsp;</span>
             @Html.RadioButtonFor(model => model.ISUSER, 0, new { @onclick = "changeShowDivUser(this.value);" })
            <span>否&nbsp;</span>
             @Html.ValidationMessageFor(model => model.ISUSER)
         </p>
         <div style="display:none;" id="divUser">
         <p>
          <label>
                用户名：</label>
            @Html.TextBoxFor(model => model.USERNAME)
         </p>
         <p>
          <label>
                登录密码：</label>
            @Html.TextBox("LOGPWD","", new { @onchange = "changePwd()" })
            @Html.Hidden("HID_LOGPWD")
         </p>
         <p>
          <label>
                用户类型：</label>
             @Html.RadioButtonFor(model => model.USERTYPE, 1)
            <span>管理员&nbsp;</span>
             @Html.RadioButtonFor(model => model.USERTYPE, 2)
            <span>一般用户&nbsp;</span>
         </p>
         </div>
         
         <p>
          <label>
                创建人：</label>
            @Html.TextBoxFor(model => model.CREATEBY, new { @readonly = "true" })
         </p>
         <p>
          <label>
                创建时间：</label>
            @Html.TextBoxFor(model => model.CREATETIME, new { @readonly = "true", @dateFmt = "yyyy-MM-dd HH:mm:ss" })
         </p>
         <p>
          <label>
                修改人：</label>
            @Html.TextBoxFor(model => model.MODIFYBY, new { @readonly = "true" })
         </p>
         <p>
          <label>
                修改时间：</label>
            @Html.TextBoxFor(model => model.MODIFYTIME, new { @readonly = "true", @dateFmt = "yyyy-MM-dd HH:mm:ss" })
         </p>
       
    </div>
    @Html.Partial("FormButtonBar")
    </form>

   <script src="/Scripts/md5.js" type="text/javascript"></script>

    <script type="text/javascript">

        changeShowDivUser(parseInt($("#HID_ISUSER").val()));
        changeShowLevalDate(parseInt($("#HID_ISLEAVE").val()));
        //设置编辑时,如果已经存在用户名，则不允许修改用户名和是否操作用户

        if (parseInt($("#ID").val()) > 0 && $("#HID_USERNAME").val() != "") {
           
            $("input[name=ISUSER]").attr("disabled", true); 
            $('#USERNAME').attr("readonly", "readonly");
        }
        if (parseInt($("#ID").val())>0)
            $("#divHolidays").css('display', 'block');
        else
            $("#divHolidays").css('display', 'none');


        function changeShowDivUser(n) {
            $("#HID_ISUSER").val(n);
            if (n == 1) {
                $("#divUser").css('display', 'block'); 
            }
            else {
                $("#divUser").css('display', 'none');
                $("#HID_LOGPWD").val("");
                $("#USERNAME").val("");
                $("#LOGPWD").val("");
                //$("#USERTYPE").val(2);
            }
        }

        function changeShowLevalDate(n) {
            if (n == 1) {
                $("#divLevalDate").css('display', 'block');
            }
            else {
                $("#divLevalDate").css('display', 'none');
               
            }
        }

        function changePwd() {
            var logPwd = $("#LOGPWD").val();
            if (logPwd != "") {
                $("#HID_LOGPWD").val(b64_md5(logPwd));  
            }
            else {
                $("#HID_LOGPWD").val("");
            }

            //alert(logPwd + "  " + $("#HID_LOGPWD").val());
           
        }
    </script>
</div>
